function serveIndex(docs, req, res) {
  var html =
  '<!DOCTYPE html>\n' +
  '<html>\n' +
  '<head><title>Post index</title></head>\n' +
  '<body>\n';
  for (var i in docs) {
    html +=
    '<div class="post">\n' +
    '<h1>' + docs[i].title + '</h1>\n' +
    '<h3>' + docs[i].created_at + '</h3>\n' +
    docs[i].body + '\n';
    for (var j in docs[i].comments) {
      html +=
      '<div class="comment">\n' +
      '<h3>' + docs[i].comments[j].author + '</h3>\n' +
      docs[i].comments[j].comment + '\n' +
      '</div>\n';
    }
    html += '</div>\n';
  }
  html += '</body>\n</html>';
  res.send(html);
}

exports.serveIndex = serveIndex;
